import './components/css/common.css'
import Vue from 'vue';
import app from './app.vue';
import MintUI from 'mint-ui';
import 'mint-ui/lib/style.css';
import '../lib/MUI/css/mui.min.css';
import '../lib/MUI/css/my.previewimage.css';

import '../lib/MUI/css/icons-extra.css';
import VueRouter from 'vue-router';
import router from'./router.js';
import VueResource from'vue-resource';
import Vuepreview from 'vue-preview';
import Vuex from 'vuex';

import VueTouch from 'vue-touch'
//引入工具类
import utils from './util.js'
Vue.prototype.$post=utils.send;
Vue.use(VueTouch, {name: 'v-touch'})

Vue.use(Vuex);
Vue.use(MintUI);
Vue.use(VueRouter);
Vue.use(VueResource);
Vue.use(Vuepreview);

Vue.prototype.url = "http://192.168.0.197:88/";
var store = new Vuex.Store({
    state:{
        count:0,
        shopcart:[
        ],
        user:{
            userName:'',
            userId:'',
            usernumber:""
        }
    },
    mutations:{
        add(state,step){
            state.count+=parseInt(step);
        },
        addCart(state,option){
            state.shopcart.unshift(option)
        },
        setNum(state,num){
            state.count=num;
        },
        addNum(state,num){
            state.conut=num;
        }
    }, 
    //不要直接通过$store.state.count去获取数据 而应该通过getters去定义一个方法来获取
    getters:{
        getCount (state){
            return state.count;//要有返回值 调用数据用$store.getters.count
        },
        getCarts(state){
            return state.shopcart
        },
    },
});
var vue = new Vue({
    el:"#app",
    render:c=>c(app), 
    router,
    store,

    
});
